package com.example.demo.strategy.CalculationStrategy;

import com.example.demo.enums.CalculationEnum;
import com.example.demo.strategy.CalculationMethodStrategy;
import org.springframework.stereotype.Service;

@Service(value = "TimeBeforeStrategy")
public class TimeBeforeStrategy implements CalculationMethodStrategy {
    @Override
    public boolean calculate(String preContent, String value) {
        long time = Long.parseLong(preContent);
        int val = Integer.parseInt(value);
        // 要将int强制转换为long类型
        if (time < val) {
            return true;
        }
        return false;
    }

    @Override
    public CalculationEnum getCalculationEnum() {
        return CalculationEnum.TIME_BEFORE;
    }
}
